import constant from '@/store/constant.js'
import common from '@/store/common.js'
const baseUrl=constant.baseUrl;
const authInfo=constant.authInfo;


export default {
	state:{//存放状态
	
		groupList:[],
		groupUserList:[],
	
	},
	mutations: {
		
		loadGroupListData(state,data){
			
			state.groupList=[]
			for(let index in data){
				state.groupList.push(data[index])
			}
		},
		
	},
	actions:{
		
		loadGroupListData(context,data){
			
			console.log("loadShareData"+JSON.stringify(data))
			uni.request({
				url: baseUrl+'/api/szm/groupListForPage',
				method: 'POST',
				header: {
						'auth': uni.getStorageSync("token") 
					},
				data: {"pageNum":data.pageNum,"pageSize":data.pageSize},
				success: (res) => {
					if(res.data.code==0){
					
						context.commit('loadGroupListData',{"data":res.data.result.data,"flag":data.flag})
						
					}else{
						common.dataError(res.data);
						console.log(res.data.message);
					}
			
				},
				fail: (err) => {
					common.jumpToLogin();
					console.log(err);
				}
			})
			
		},
		
		
	}
}